<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" name="viewport" content="width-device-width,initial-scale=1">
    <title>长流博客</title>
    <script src="/js/jquery.min.js"></script>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/ajaxGetHtml.js"></script>
    <script src="https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script>
    <script type="text/javascript" th:inline="javascript">
        var articleId = [[${blogId}]];
        $(function () {
            $.ajax({
                type:'POST',
                contentType:'application/json;charset=utf-8',
                url:'/home/getBlogById/'+articleId,
                dataType:'json',
                success:function(data) {
                    if(data['message']=="获取成功"){
                        var blog = data['result'];
                        $('#newsType').text(blog['blogType']);
                        $("#title").text(blog['title']);
                        $('#author').text(blog['author']);
                        $('#time').text(blog['publishTime']);
                        $('#content').html(blog['content']);
                    }else {
                        alert("获取失败");
                    }
                },
                error:function (err) {
                    alert(err.responseText);
                }
            })
            $('#copy-content').val("https://tyu.wiki/home/blog/"+articleId);
        })
        function backPre() {
            location.href = document.referrer;
        }
        function backHome(){
            $(location).attr('href',"/home/blog");
        }
        function share() {
            var copyObject=document.getElementById("copy-content");
            copyObject.select();
            document.execCommand("Copy");
            alert("粘贴分享~");
        }
    </script>
</head>
<body>
<div th:include="public/header"></div>
<div class="page-header container">

    <span class="label label-info"><span id="newsType"></span></span>
    <a class="btn btn-default" onClick="backPre()">返回上一层</a>
    <a class="btn btn-default" onclick="backHome()">返回主页</a>
    <a class="btn btn-default" onclick="share()">分享</a>
    <h1><span id="title"></span>
        <small>
            作者：<span id="author"></span>——<span id="time"></span>
        </small>
    </h1>
    <br>
    <span id="content"></span>
    <span>本文链接</span><input id="copy-content" readonly/>
</div>
<div th:include="public/footer"></div>
</body>
</html>